home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SCRIB6.PAK / SCRIBDOC.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  121 lines

  1. // ScribDoc.h : interface of the CScribbleDoc class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. /////////////////////////////////////////////////////////////////////////////
  13.  
  14. // Forward declaration of data structure class
  15. class CStroke;
  16.  
  17. class CScribbleDoc : public CDocument
  18. {
  19. protected: // create from serialization only
  20.     CScribbleDoc();
  21.     DECLARE_DYNCREATE(CScribbleDoc)
  22.  
  23. // Attributes
  24. protected:
  25.     // The document keeps track of the current pen width on
  26.     // behalf of all views. We'd like the user interface of
  27.     // Scribble to be such that if the user chooses the Draw
  28.     // Thick Line command, it will apply to all views, not just
  29.     // the view that currently has the focus.
  30.  
  31.     UINT            m_nPenWidth;        // current user-selected pen width
  32.     BOOL            m_bThickPen;        // TRUE if current pen is thick
  33.     UINT            m_nThinWidth;
  34.     UINT            m_nThickWidth;
  35.     CPen            m_penCur;           // pen created according to
  36.                                         // user-selected pen style (width)
  37. public:
  38.     CTypedPtrList<CObList,CStroke*>     m_strokeList;   
  39.     CPen*           GetCurrentPen() { return &m_penCur; }
  40.  
  41. protected:
  42.     CSize           m_sizeDoc;
  43. public:
  44.     CSize GetDocSize() { return m_sizeDoc; }
  45.  
  46. // Operations
  47. public:
  48.     CStroke* NewStroke();
  49.  
  50. // Overrides
  51.     // ClassWizard generated virtual function overrides
  52.     //{{AFX_VIRTUAL(CScribbleDoc)
  53.     public:
  54.     virtual BOOL OnNewDocument();
  55.     virtual void Serialize(CArchive& ar);
  56.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  57.     virtual void DeleteContents();
  58.     //}}AFX_VIRTUAL
  59.  
  60. // Implementation
  61. protected:
  62.     void ReplacePen();
  63.  
  64. public:
  65.     virtual ~CScribbleDoc();
  66. #ifdef _DEBUG
  67.     virtual void AssertValid() const;
  68.     virtual void Dump(CDumpContext& dc) const;
  69. #endif
  70.  
  71. protected:
  72.     void            InitDocument();
  73.  
  74. // Generated message map functions
  75. protected:
  76.     //{{AFX_MSG(CScribbleDoc)
  77.     afx_msg void OnEditClearAll();
  78.     afx_msg void OnPenThickOrThin();
  79.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  80.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  81.     afx_msg void OnPenWidths();
  82.     //}}AFX_MSG
  83.     DECLARE_MESSAGE_MAP()
  84. };
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. // class CStroke
  88. //
  89. // A stroke is a series of connected points in the scribble drawing.
  90. // A scribble document may have multiple strokes.
  91.  
  92. class CStroke : public CObject
  93. {
  94. public:
  95.     CStroke(UINT nPenWidth);
  96.  
  97. protected:
  98.     CStroke();
  99.     DECLARE_SERIAL(CStroke)
  100.  
  101. // Attributes
  102. protected:
  103.     UINT                   m_nPenWidth;    // one pen width applies to entire stroke
  104. public:
  105.     CArray<CPoint,CPoint>  m_pointArray;   // series of connected points
  106.     CRect               m_rectBounding; // smallest rect that surrounds all
  107.                                         // of the points in the stroke
  108.                                         // measured in MM_LOENGLISH units
  109.                                         // (0.01 inches, with Y-axis inverted)
  110. public:
  111.     CRect& GetBoundingRect() { return m_rectBounding; }
  112.  
  113. // Operations
  114. public:
  115.     BOOL DrawStroke(CDC* pDC);
  116.     void FinishStroke();
  117.  
  118. public:
  119.     virtual void Serialize(CArchive& ar);
  120. };
  121.